using UnityEngine;
using System.Collections;
using FM_Mono;

[IgnoreGen]
public class TextureTilingOffsetAdjustor : MonoBehaviour
{
	private static MaterialPropertyBlock mpb = null;

	public Vector4 tilingOffset = new Vector4(1, 1, 0, 0);

    public string TilingOffsetName;

	[ContextMenu("Execute")]
	void Start()
	{
		Renderer renderer = GetComponent<Renderer> ();

		if (mpb == null)
		{
			mpb = new MaterialPropertyBlock ();
		}
		renderer.GetPropertyBlock (mpb);
        mpb.SetVector(TilingOffsetName, tilingOffset);
		renderer.SetPropertyBlock(mpb);
		//AssetBundleManager.GetBundle("dataconfig", getdata);
	}

#if UNITY_EDITOR
	void Update()
	{	
		Renderer renderer = GetComponent<Renderer> ();
		renderer.GetPropertyBlock (mpb);
		mpb.SetVector (TilingOffsetName, tilingOffset);
		renderer.SetPropertyBlock (mpb);
		//	GetComponent<Renderer>().materials[0].mainTextureOffset = v1;
	}
#endif
}
